// React基础组件
import React from 'react'
// dva 连接组件 - 连接route和model
import { connect } from 'dva'
// 引入antd的组件
import { Tabs,Form,Popconfirm, Upload, message, Button, Modal, Row, Col, Input,Table, Divider,Icon,Select, Radio,DatePicker,Tooltip} from 'antd'
//导入路由组件，用于跳转等
import { Link, hashHistory } from 'dva/router'
// 导入项目全局配置文件
import config from 'config/config' 
import ListPage from 'widget/PageTmpl/ListPage'
// 引入model取值工具方法
import { mapStateToProps } from 'utils/view_utils'
// 当前组件样式
import styles from './integralMemberDetailStyle.less'
let cx = classnames.bind(styles);
import classnames from 'classnames/bind';
import { CollapsiblePanels } from 'widget/CollapsiblePanels/index'
import { Grid } from 'widget/Grid/index'
const TabPane = Tabs.TabPane
const FormItem = Form.Item
const formItemLayout = {
    labelCol: { span: 6 },
    wrapperCol: { span: 18 },
  }
/**
 * description 路由视图及事件处理
 * dispatch 分发到models中的effects对应事件名
 * model 用于获取models中state定义的数据
 * form 表单对象
 */
const routeView = function({dispatch, model, form}) {
  // 表单的子函数
  const {resetFields, getFieldDecorator, validateFields, setFieldsValue} = form
  // 取出model对象，命名空间
  const { modelObj, namespace } = model
   // modelObj.xxx获取model中状态机的值
   let {memberDetail,productList,integralList} = modelObj

  let productListColumns = [ 
    {title: '项目id', dataIndex: 'projectCode', key: 'projectCode',width:250},
    {title: '项目名称', dataIndex: 'projectName', key: 'projectName',width:150},
    {title: '资产id', dataIndex: 'assetId', key: 'assetId',width:250},
    {title: '资产名称', dataIndex: 'assetName', key: 'assetName',width:150}
  ]
  //  const productModalData = {
  //   columns: productListColumns,
  //   tableData: {total: '', dataSource: productList},
  //   pageConfig: {
  //     current: 1,
  //     pageSize: productList?productList.length:100
  //   }
  // }

  let integralListColumns = [
    {title: '积分', dataIndex: 'integral', key: 'integral',width:100},
    {title: '积分来源名称', dataIndex: 'integralname', key: 'integralname',width:200},
    {title: '规则', dataIndex: 'rule', key: 'rule',width:100},
    {title: '时间', dataIndex: 'dtime', key: 'dtime',width:200},
    {title: '项目名称', dataIndex: 'projectname', key: 'projectname',width:200},
    {title: '区域', dataIndex: 'regionname', key: 'regionname',width:100},
    {title: '备注', dataIndex: 'reamrk', key: 'reamrk',width:200}
  ]
  //  const integralModalData = {
  //   columns: integralListColumns,
  //   tableData: {total: '', dataSource: integralList},
  //   pageConfig: {
  //     current: 1,
  //     pageSize: integralList?integralList.length:100
  //   }
  // }
  return (
    <div className={cx('pageLayout')}>
      <div className='public_listMain'>
        <Form>
            <CollapsiblePanels title={'积分会员'} hideUpDownBtn={true}>
              <Row>
				    <Col span={6}>
                    <FormItem
                        {...formItemLayout}
                        label="业主姓名">
                        {getFieldDecorator('yzname', {
                            initialValue: memberDetail.yzname ? memberDetail.yzname : ''
                        })(<Input
                            disabled={true}
                        />)}
                        </FormItem>
					</Col>
                    <Col span={6}>
                        <FormItem
                        {...formItemLayout}
                        label="业主电话">
                        {getFieldDecorator('yzmobile', {
                            initialValue: memberDetail.yzmobile ? memberDetail.yzmobile : ''
                        })(<Input
                            disabled={true}
                        />)}
                        </FormItem>
                    </Col>
                    <Col span={6}>
                        <FormItem
                        {...formItemLayout}
                        label="业主身份证">
                        {getFieldDecorator('zyx1', {
                            initialValue: memberDetail.zyx1 ? memberDetail.zyx1 : ''
                        })(<Input
                            disabled={true}
                        />)}
                        </FormItem>
                    </Col>
                    <Col span={6}>
                        <FormItem
                        {...formItemLayout}
                        label="会员等级">
                        {getFieldDecorator('yzLevel', {
                            initialValue: memberDetail.yzLevel ? memberDetail.yzLevel : ''
                        })(<Input
                            disabled={true}
                        />)}
                        </FormItem>
                    </Col>
              </Row>
			  <Row>
              <Col span={6}>
                <FormItem
                  {...formItemLayout}
                  label="当前积分">
                  {getFieldDecorator('dqIntegral', {
                    initialValue: memberDetail.dqIntegral ? memberDetail.dqIntegral : '0'
                  })(<Input
                    disabled={true}
                  />)}
                </FormItem>
              </Col>
              <Col span={6}>
                <FormItem
                  {...formItemLayout}
                  label="累计积分">
                  {getFieldDecorator('ljIntegral', {
                    initialValue: memberDetail.ljIntegral ? memberDetail.ljIntegral : '0'
                  })(<Input
                    disabled={true}
                  />)}
                </FormItem>
              </Col>
              <Col span={6}>
                <FormItem
                  {...formItemLayout}
                  label="区域">
                  {getFieldDecorator('regionname', {
                    initialValue: memberDetail.regionname ? memberDetail.regionname : ''
                  })(<Input
                    disabled={true}
                  />)}
                </FormItem>
              </Col>
			  </Row>
                {/* <TabPane tab="积分会员子表" key="1">
                    <Grid nameSpace={`${namespace}`} data={productModalData}
                          scroll={{x: 500}}
                          loading={false}
                          isDisplayOrder={true}
                          paginationFlag={false}
                    />
                </TabPane> */}
            </CollapsiblePanels>
            <CollapsiblePanels title={'积分会员子表'} hideUpDownBtn={true}>
                <div className={cx('margin')}>
                <Table
                    columns={productListColumns}
                    dataSource={productList}
                // pagination={pagination}
                />
                {/* <Grid nameSpace={`${namespace}`} data={productModalData}
                        scroll={{x: 1200}}
                        loading={false}
                        isDisplayOrder={false}
                        paginationFlag={false}
                /> */}
                </div>
                <Table
                    columns={integralListColumns}
                    dataSource={integralList}
                // pagination={pagination}
                />
                {/* <Grid nameSpace={`${namespace}`} data={integralModalData}
                        scroll={{x: 1200}}
                        loading={false}
                        isDisplayOrder={false}
                        paginationFlag={false}
                /> */}
                
            </CollapsiblePanels>
        </Form>
      </div>
    </div>
  )
}

// 连接视图(view)和模型(model)
export default connect(mapStateToProps)(Form.create()(routeView))